#!/bin/bash

echo "检查Python安装..."

if ! command -v python3 &> /dev/null; then
    echo "Python未安装，正在下载并安装Python..."
    
    # 检查是否安装了Homebrew
    if ! command -v brew &> /dev/null; then
        echo "正在安装Homebrew..."
        /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    fi
    
    echo "使用Homebrew安装Python..."
    brew install python@3.8
    
    # 添加Python到PATH
    echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
else
    echo "Python已安装"
fi

echo "检查jxlang是否已安装..."
if ! python3 -c "import jxlang" &> /dev/null; then
    echo "jxlang未安装，正在安装..."
    pip3 install jxlang -i https://pypi.tuna.tsinghua.edu.cn/simple
else
    echo "jxlang已安装,下次启动时请在终端输入jxlang即可启动"
fi
